package cn.iocoder.an.module.mold.dal.mysql.devcategory;

import java.util.*;

import cn.iocoder.an.framework.common.pojo.PageResult;
import cn.iocoder.an.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.an.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.an.module.mold.dal.dataobject.devcategory.DevCategoryDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.an.module.mold.controller.admin.devcategory.vo.*;

/**
 * 设备分类 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface DevCategoryMapper extends BaseMapperX<DevCategoryDO> {

    default List<DevCategoryDO> selectList(DevCategoryListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DevCategoryDO>()
                .eqIfPresent(DevCategoryDO::getStatus, reqVO.getStatus())
                .likeIfPresent(DevCategoryDO::getCode, reqVO.getCode())
                .likeIfPresent(DevCategoryDO::getName, reqVO.getName())
                .eqIfPresent(DevCategoryDO::getUpkeepCategory, reqVO.getUpkeepCategory())
                .eqIfPresent(DevCategoryDO::getParentId, reqVO.getParentId())
                .betweenIfPresent(DevCategoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DevCategoryDO::getId));
    }

	default DevCategoryDO selectByParentIdAndName(Long parentId, String name) {
	    return selectOne(DevCategoryDO::getParentId, parentId, DevCategoryDO::getName, name);
	}

    default Long selectCountByParentId(Long parentId) {
        return selectCount(DevCategoryDO::getParentId, parentId);
    }

}